package com.redoor.app.stake.workflow.controller;

import com.redoor.app.stake.workflow.model.BaseWorkorder;
import com.redoor.app.stake.workflow.service.BaseWorkOrderRedisService;
import com.redoornetwork.framework.core.response.ResponseResult;
import com.redoornetwork.framework.core.response.ResultGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wangjunlei on 2018/3/30.
 */
@RestController
@RequestMapping("/base/workorders/redis")
public class BaseWorkOrderRedisController {

    @Autowired
    private BaseWorkOrderRedisService baseWorkOrderRedisService;

    @PostMapping
    public ResponseResult add(@RequestBody BaseWorkorder baseWorkorder) {
        baseWorkOrderRedisService.putRemindWorkOrderToRedis(baseWorkorder);
        return ResultGenerator.generatorSuccess();
    }

    @PostMapping("/get")
    public ResponseResult get(String orgno) {
        BaseWorkorder baseWorkorder = baseWorkOrderRedisService.getRemindWorkOrderFromRedis(orgno);
        return ResultGenerator.generatorSuccess(baseWorkorder);
    }
}
